def addBinary(a, b):
    ans = ''
    carry = 0
    len_a, len_b = len(a), len(b)
    n = max(len_b, len_a)
    for i in range(n):
        if i < len_a:
            carry += int(a[len_a - i - 1])
        if i < len_b:
            carry += int(b[len_b - i - 1])
        ans = str(carry % 2) + ans
        carry //= 2
    if carry > 0:
        ans = '1' + ans
    return ans


print(addBinary('11', '1'))  # 100
print(addBinary('1010', '1011'))  # 10101
